package com.pkuse.bjousystem.repository.student;

import com.pkuse.bjousystem.dto.student.XueShengBiYeNianDuXueQiDTO;
import com.pkuse.bjousystem.entity.student.XueShengBiYe;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface XueShengBiYeRepository extends CrudRepository<XueShengBiYe, String> {

    @Query("select distinct new com.pkuse.bjousystem.dto.student.XueShengBiYeNianDuXueQiDTO(xsbyb.bynd, xsbyb.byxq, xqdmb.xqmc) " +
            "from XueShengBiYe xsbyb inner join Student xsb on (xsbyb.xh=xsb.xh and xsbyb.bynd is not null and xsbyb.byxq is not null and (:xxdm is null or xsb.xxdm = :xxdm))" +
            "inner join XueQiDaiMa xqdmb on xqdmb.xqdm=xsbyb.byxq")
    List<XueShengBiYeNianDuXueQiDTO> listBiYeXueQiForGraduation(@Param("xxdm") String xxdm);
}
